package com.example.week3.mvp.view.fragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.mylibrary.retrofit.RetrofitManager;
import com.example.week3.R;
import com.example.week3.adapter.TravelAdapter;
import com.example.week3.api.Api;
import com.example.week3.bean.UserBean;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * A simple {@link Fragment} subclass.
 */
public class Pig1Fragment extends Fragment {
    private static final String TAG = "TAG";
    TravelAdapter travelAdapter;
    View inflate;
    private RecyclerView rv;
    private List<List<UserBean>> list=new ArrayList();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        inflate = inflater.inflate(R.layout.fragment_pig1, container, false);
        rv = (RecyclerView)inflate. findViewById(R.id.rv);
        initData();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        linearLayoutManager.setOrientation(RecyclerView.HORIZONTAL);
        rv.setLayoutManager(linearLayoutManager);
        travelAdapter = new TravelAdapter(R.layout.item, list);
        rv.setAdapter(travelAdapter);
        return inflate;

    }

    private void initData() {
         new RetrofitManager().getInstance().getRetrofit()
                .create(Api.class)
                .tag()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<UserBean>() {
             @Override
             public void onSubscribe(Disposable d) {

             }

             @Override
             public void onNext(UserBean userBean) {

             }

             @Override
             public void onError(Throwable e) {

             }

             @Override
             public void onComplete() {

             }
         });

    }


}
